<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
    <link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>添加商户</title>
    <script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script>
    <script src="../lib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <!--/_footer 作为公共模版分离出去-->

    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript" src="../lib/My97DatePicker/4.8/WdatePicker.js"></script>
    <script type="text/javascript" src="../lib/jqueryPage/paging.min.js"></script>
    <script type="text/javascript" src="../lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="../lib/laypage/1.2/laypage.js"></script>
    <script src="../lib/jrender.min.js" type="text/javascript"></script>

    <script src="../js/config.js"></script>
    <script>
    </script>
</head>

<body>
    <article class="page-container">
        <form class="form form-horizontal" id="cForm">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>原密码：</label>
                <div class="formControls col-xs-4 col-sm-5">
                    <input type="password" class="input-text" placeholder="原密码" name="oldpass" id="oldpass">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>新密码：</label>
                <div class="formControls col-xs-4 col-sm-5">
                    <input type="password" class="input-text" name="newpass1" placeholder="新密码" id="newpass1" />
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>确认密码：</label>
                <div class="formControls col-xs-4 col-sm-5">
                    <input type="password" class="input-text" name="newpass2" placeholder="确认密码" id="newpass2" />
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input id="updata-btn" class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
    <script class="resources library" src="../js/area.js" type="text/javascript"></script>
    <script>
        $(function () {　
            var account = $.cookie('user__userName');
            var md5 = $.cookie('user__code');

            $("#cForm").validate({　　
                onsubmit: true, // 是否在提交是验证
                　　onfocusout: false, // 是否在获取焦点时验证
                　　onkeyup: false, // 是否在敲击键盘时验证
                rules: {　　　　 //规则
                    oldpass: {　　 //要对应相对应的input中的name属性
                        required: true　　
                    },
                    newpass1: {　　　　
                        required: true　　
                    },
                    newpass2: {　　　　
                        required: true　,
                        equalTo: "#newpass1"　
                    }
                },
                messages: {　　　　 //验证错误信息
                    oldpass: {　　　　
                        required: "请输入旧密码"　　　　
                    },
                    newpass1: {　　　　
                        required: "请输入新密码"　　
                    },
                    newpass2: {　　　　
                        required: "请输入确认密码密码",
                        equalTo: "两次密码输入不一致"
                    }
                },
                submitHandler: function (form) { //通过之后回调
                    $('#updata-btn').attr('disabled', true);
                    $.ajax({
                        type: 'POST',
                        url: $.webConfig.basicUrl + '/chuyangPay/user/updateUserPwd',
                        data: {
                            account: account,
                            md5: md5,
                            oldPwd: $('#oldpass').val(),
                            newPwd: $('#newpass1').val()
                        },
                        dataType: "json",
                        success: function (data) {
                            if (data['code'] == 200) {
                                layer.alert('修改成功，请重新登录');
                                setTimeout(function () {
                                    $.cookie('user__userName', null, {
                                        expires: -1,
                                        path: '/'
                                    });
                                    $.cookie('user__code', null, {
                                        expires: -1,
                                        path: '/'
                                    });
                                    $.cookie('user_mcno', null, {
                                        expires: -1,
                                        path: '/'
                                    });
                                    $.cookie('userall__code', null, {
                                        expires: -1,
                                        path: '/'
                                    });
                                    top.document.location.href = "/user/login.html";
                                }, 600);
                            } else {
                                layer.alert(data['msc']);
                            }
                            $('#updata-btn').removeAttr('disabled');
                        },
                        error: function (err) {
                            console.log(err);
                            $('#updata-btn').removeAttr('disabled');

                        }
                    })



                },
                invalidHandler: function (form, validator) {
                    return false;
                }
            });
        });
    </script>
</body>

</html>